﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReserveMenu.aspx.cs" Inherits="WeChat.MenuReservation.ReserveMenu" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>菜单预定</title>
    <script src="../Script/rem.js"></script>
    <script src="../Script/jquery.min.js" type="text/javascript"></script>
    <script src="../Script/jquery-1.8.3.min.js?v=1.1"></script>
    <script src="../Scripts/mobiscroll-2.13.2.full.min.js?v=1.2"></script>
    <link href="../Content/mobiscroll-2.13.2.full.min.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <link rel="stylesheet" type="text/css" href="../css/page.css" />
    <link rel="stylesheet" type="text/css" href="../css/all.css" />
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/loaders.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/loading.css" />
    <link href="../Script/slick/slick.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css" />
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="../Script/JquerySession.js"></script>
    <script src="../Script/mui.min.js"></script>

    <script src="../Script/others.js"></script>
    <script type="text/javascript" src="../Script/hmt.js"></script>
    <script src="../Script/slick/slick.js" type="text/javascript"></script>
    <script src="../Script/shopcar.js"></script>
    <!--插件-->
    <link rel="stylesheet" href="../css/swiper.min.css" />
    <script src="../Script/swiper.jquery.min.js"></script>
    <script src="../Script/iconfont.js"></script>
    <link href="../Script/iconfont.css" rel="stylesheet" />
    <link href="../Script/slick/iconfont.css" rel="stylesheet" />
    <script src="../Script/slick/iconfont.js"></script>




    <style type="text/css">
        #contentleft ul {
            background-color: #427DBF;
            padding-top: 10px;
        }

            #contentleft ul li {
                line-height: 50px;
                text-align: center;
            }

                #contentleft ul li.current {
                    position: relative;
                    background: #fff;
                    color: #fc8f00;
                    border-bottom: 0;
                    height: auto;
                    line-height: 50px;
                    font-weight: 700;
                }
    </style>



    <script type="text/javascript">
        $(window).load(function () {
            $(".loading").addClass("loader-chanage")
            $(".loading").fadeOut(300)
        })
        var state2 = "";        
        var meunumberlist = [];
        //根据时间段查询展示可订菜单
        function SelectTimeState(state) {

            meunumberlist = [];
            //加载获取菜品分类
            getFoodCategoryTwo();

            $(".all").empty();
            $("#sum").empty();
            $("[name='count']").empty();
            var canteen = $("#canteen").val();
            var Trade_name = $("#Trade_name").val();
            //console.log("获取食堂：" + canteen);
            if (canteen != "超市") {

                $("#lunch").css("display", "block");
                $("#dinner").css("display", "block");
                $("#breakfast").css("display", "block");
                $("#midnightSnack").css("display", "none");
                $("#supermarket").css("display", "none");
            }
            else {

                $("#lunch").css("display", "none");
                $("#dinner").css("display", "none");
                $("#breakfast").css("display", "none");
                $("#midnightSnack").css("display", "block");
                $("#supermarket").css("display", "none");
                console.log("输出！");
            }



            $("#lunch,#dinner,#midnightSnack,#breakfast,#supermarket").removeClass("cur");
            $("#" + state).addClass("cur");
            state2 = state;

            var hah = $("#seldate_dummy").val();//获取选择预定的时间
            if (typeof (hah) == "undefined") {
                var rr = new Date();
                rr = rr.getFullYear() + "-" + (rr.getMonth() + 1) + "-" + rr.getDate();
            }
            else {
                rr = hah;
            }


            $("#contentleft ul li").siblings('li').removeClass('current');  // 删除其他兄弟元素的样式
            $("#contentleft ul li:first").addClass('current');
            $("[name='menus']").remove();
            $.ajax({
                type: "post",
                url: "../MenuReserveHandler.ashx",
                async: false,
                data: { TimeState: state, rr: rr, canteen: canteen, Trade_name: Trade_name, funcName: 'getMenuList' },
                success: function (data) {

                    if (data == null) return;
                    data = $.parseJSON(data);
                    var item = $.parseJSON(data.baseInfo);
                    $("#empty").remove();
                    if (item == null || item == "") {
                        $("#content").prepend('<div style="text-align:center;padding-top:3rem;" id="empty"><img src="../images/caip.png" style="width:2rem;"/><p style="padding-top:.3rem">商家未提供该时间段商品</p></div>');
                    }
                    else {
                        var Inventories = "";
                        for (var i = 0; i < item.length; i++) {
                            var menuName = item[i].Name;
                            var price = item[i].Price;
                            var state = item[i].TimeStateId;

                            //var OnSaleId = item[i].onsaleid;
                            var OnSaleId = item[i].OnSaleId1;
                            var Image = item[i].Image;
                            if (canteen == "超市") {
                                Inventories = item[i].Inventories;
                            }
                            else {
                                Inventories = item[i].ShelvesNum;
                            }
                            var sdmc = item[i].sdmc.trim() == "前夜餐" ? "夜宵" : item[i].sdmc.trim();

                            // $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div ><img src="../' + Image + '" onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a > <div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a>                        <span class="fr db" name="add" onclick="add(\'' + menuName + '\',' + price + ',\'' + sdmc + '\',' + OnSaleId + ')"><img src="../images/newUI/add.png" /></span></div><div> 剩余:' + Inventories + '</div>  </div ></div ></div>');
                            // $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div class="tu clearfloat fl"><img src="../' + Image + '" onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a > <div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a>                        <span class="fr db" name="add" onclick="add(\'' + menuName + '\',' + price + ',\'' + sdmc + '\',' + OnSaleId + ')"><img src="../images/newUI/add.png" /></span></div> <div> 剩余:' + Inventories + '</div> </div ></div ></div>');
                            if (sdmc == "早餐") {
                                $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div class="tu clearfloat fl"><img src="../' + Image + '" onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a ><div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a> </div ></div ></div>');
                            }
                            else {
                                // $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div ><img src="../' + Image + '" onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a > <div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a>                        <span class="fr db" name="add" onclick="add(\'' + menuName + '\',' + price + ',\'' + sdmc + '\',' + OnSaleId + ')"><img src="../images/newUI/add.png" /></span></div><div> 剩余:' + Inventories + '</div>  </div ></div ></div>');
                                //$("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div class="tu clearfloat fl"><img src="../' + Image + '" onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a > <div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a>                        <span class="fr db" name="add" onclick="add(\'' + menuName + '\',' + price + ',\'' + sdmc + '\',' + OnSaleId + ')"><img src="../images/newUI/add.png" /></span></div> <div> 剩余:' + Inventories + '</div> </div ></div ></div>');
                                if (canteen == "超市") {
                                    var myName = new Array();
                                    myName.push($(this).text());
                                    $($(".tit")).each(function () {
                                        myName.push($(this).text());
                                    });
                                    if (myName.indexOf(menuName) == -1) {
                                        $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div class="tu clearfloat fl"><img src="../' + Image + '" style="height:80px;"  onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a > <div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a>                        <span class="fr db" name="add" onclick="add(\'' + menuName + '\',' + price + ',\'' + sdmc + '\',' + OnSaleId + ')"><img src="../images/newUI/add.png" /></span></div> <div> 剩余:' + Inventories + '</div> </div ></div ></div>');
                                    }
                                }
                                else {
                                    $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div class="tu clearfloat fl"><img src="../' + Image + '" style="height:80px;"  onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a > <div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a>                        <span class="fr db" name="add" onclick="add(\'' + menuName + '\',' + price + ',\'' + sdmc + '\',' + OnSaleId + ')"><img src="../images/newUI/add.png" /></span></div> <div> 剩余:' + Inventories + '</div> </div ></div ></div>');
                                }
                            }
                        }
                    }
                },
                error: function () {
                    alert("异常！");
                }
            });
        }
        //设置图片放大
        function tupian(image) {
            $("body").append('<div class="sharebg" style="text-align:center;"></div>');
            $(".sharebg").addClass("sharebg-active");
            $(".sharebg").prepend("<img src=" + image + " style='width:70%;margin-top:50%;height:auto; border-radius: 15px;'  onclick='closed()'>");
        }
        //关闭放大图片
        function closed() {
            $(".sharebg").remove();
        }
        var clickCount = 0;
        function submit() {    //点击确定按钮，把获取订单号，并把订单信息加入数据库 
            clickCount++
            if (clickCount > 1) {
                alert("请勿重复提交！");
                return false;
            }
            var openid = $("#openid").text();
            var canteen = $("#canteen").val();
            $.ajax({
                type: "post",
                url: "../MenuReserveHandler.ashx",
                data: { funcName: 'getGuid' },
                success: function (result) {


                    var sum = $("#sum").text();
                    //$($(".datetime")).each(function () {
                    //    var languageJson = {};
                    //    $($(this).parents(".all").find("[name = 'myCount']")).each(function () {
                    //        m = $(this).parents(".bottom").attr("data-id");       //上架ID       
                    //        languageJson[m] = $(this).text();
                    //    });
                    //    var date = $(this).text();
                    //    $.ajax({
                    //        type: "post",
                    //        url: "../MenuReserveHandler.ashx",
                    //        data: { json: JSON.stringify(languageJson), OrderId: result, date: date, type: "other", funcName: "AddOrderDetail" },
                    //    });
                    //});

                    //var state = "";
                    //if (deductions == "是") {//扣款
                    //    state = "1";
                    //} else {
                    //    state = "2";
                    //}

                    //$.ajax({
                    //    type: "post",
                    //    url: "../MenuReserveHandler.ashx",
                    //    data: { OrderId: result, totalPrice: sum, openid: openid, state: state, funcName: "AddOrderList" },
                    //    success: function () {
                    //        debugger
                    //        if (deductions == "否") {//订餐成功
                    //            $("#toast").css("display", "block");
                    //            setTimeout(" window.location.href = 'ReserveMenu.aspx'", 2000)
                    //        }
                    //    }
                    //});

                    var state = "";
                    if (deductions == "是") {//扣款
                        state = "1";
                    } else {
                        state = "2";
                    }

                    $($(".datetime")).each(function () {
                        var languageJson = {};
                        $($(this).parents(".all").find("[name = 'myCount']")).each(function () {
                            m = $(this).parents(".bottom").attr("data-id");       //上架ID       
                            languageJson[m] = $(this).text();
                        });
                        var date = $(this).text();
                        $.ajax({
                            type: "post",
                            url: "../MenuReserveHandler.ashx",
                            data: {
                                json: JSON.stringify(languageJson), OrderId: result, date: date, type: "other",
                                totalPrice: sum, openid: openid, state: state, canteen: canteen, funcName: "AddOrderDetail_AllIn"

                            },
                        });
                    });


                    if (deductions == "是")//扣款，跳转至支付页面
                    {
                          //window.location.href = "../JsSDK/WxPay/SubmitOrder.aspx?price=" + $("#sum").text() + "&OrderID=" + result + "&openid=" + openid + "&wxopenid=" + '<%=wxopenid%>';
                          window.location.href = "../JsSDK/WxPay/SubmitOrder.aspx?price=" + $("#sum").text() + "&seldate_dummy=" + $("#seldate_dummy").val() + "&OrderID=" + result + "&openid=" + openid + "&wxopenid=" + '<%=wxopenid%>';

                    }


                },
                error: function () {
                    alert("异常！");
                }
            });
        }


       // meunumberlist = [];
        //加入订单按钮
        function add(name, price, sdmc, OnSaleId) {


            //图片闪动
            var div = $("img");
            div.animate({ left: '40px', opacity: '0.4' }, "slow");
            div.animate({ bottom: '300px', opacity: '0.8' }, "slow");


            var height = $(window).height();
            var cc = $("#determine").height();
            //console.log($("#openid").text());
            $(".am-share-sns").css("height", height - cc);

            var canteen = $("#canteen").val();

            //点击事件做出判断
            $.ajax({
                type: "post",
                url: "../MenuReserveHandler.ashx",
                dataType: "json",
                async: false,
                data: { sdmc: sdmc, openid: $("#openid").text(), seldate_dummy: $("#seldate_dummy").val(), canteen: $("#canteen").val(), meunumberlist: JSON.stringify(meunumberlist), onsaleid: OnSaleId, funcName: 'meulimitnum' },
                success: function (data) {
                    if (data == false && canteen == "超市") {
                        alert("此商品已售完，无法购买，不便之处敬请谅解！");
                        return false;
                    }
                    else if (data == false && canteen != "超市") {
                        alert("此时段订餐餐次已达上限、或份数不足，无法再次购买，不便之处敬请谅解！");
                        return false;
                    }
                    else {
                        //var canteen = $("#canteen").val();
                        var datetime = $("#seldate_dummy").val();//获取选择预定的时间
                        $.ajax({
                            type: "post",
                            url: "../MenuReserveHandler.ashx",
                            dataType: "json",
                            async: false,
                            data: { sdmc: sdmc, canteen: canteen, openid: $("#openid").text(), funcName: 'getTimeState' },
                            success: function (data) {
                                for (var i = 0; i < data.length; i++) {
                                    var cskssj = data[i].sd1;
                                    var csjssj = data[i].sd2;
                                    if (sdmc.trim() == "早餐") {
                                        var kssj = data[i].sd1;
                                        var jssj = data[i].sd2;
                                    } if (sdmc.trim() == "午餐") {
                                        var kssj = data[i].sd3;
                                        var jssj = data[i].sd4;
                                    } if (sdmc.trim() == "晚餐") {
                                        var kssj = data[i].sd5;
                                        var jssj = data[i].sd6;
                                    } if (sdmc.trim() == "夜宵") {
                                        var kssj = data[i].sd7;
                                        var kssj = data[i].sd8;
                                    }



                                    //var sdmc = data[i].sdmc;
                                    //var kssj = data[i].kssj;
                                    if (datetime == "")//如果时间为空则弹框提醒
                                    {
                                        $(".weui-dialog__bd").html("请选择用餐时间");
                                        $("#dialog").css("display", "block");
                                    } else {

                                        if (canteen != "超市") {

                                            var d = new Date();
                                            c = d.setMinutes(d.getMinutes() + reservationtime);
                                            c = new Date(c);//最后可订餐时间
                                            var b = datetime.replace(/\-/g, '/') + " " + kssj;//对应时段开始就餐时间
                                            b = new Date(b);

                                            //if (new Date(a) > new Date(b)) {
                                            if (c > b) {
                                                $(".weui-dialog__bd").html("已不能订购今天的" + sdmc);
                                                $("#dialog").css("display", "block");
                                                return;
                                            }
                                            else {
                                                //添加购物车列表
                                                meunumberlist.push({ "onsaleid": OnSaleId, "name": name, "number": 1 });

                                                var myar = new Array();
                                                $($("[name='" + datetime + "']")).each(function () {
                                                    myar.push($(this).text());
                                                });
                                                var arr = new Array();
                                                $($("[name='" + datetime + "']").parents(".all").find(".tit")).each(function () {
                                                    arr.push($(this).attr("name"));
                                                });
                                                //debugger
                                                // 包含该日期
                                                if (myar.indexOf(datetime) != -1) {
                                                    var myarr = new Array();
                                                    $($("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='ww']")).each(function () {
                                                        myarr.push($(this).text());
                                                    });
                                                    if (arr.indexOf(sdmc) != -1) {//包含该时间段的菜品
                                                        if (myarr.indexOf(name) != -1) { //如果提交菜单弹出项已包含该菜品
                                                            $("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='" + sdmc + "']").siblings(".bottom").find("[name='" + name + "']").parents(".bottom").find("[name='myCount']").text(function (n, c) { return Number(c) + 1 });
                                                            $("[name='count']").text(function (n, c) { return Number(c) + 1 });
                                                            $("[name='sum']").text(function (n, c) { return (Number(c) + Number(price)).toFixed(2) });
                                                        } else {
                                                            if ($("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='" + sdmc + "']").text() == "") {
                                                                $("[name='" + datetime + "']").parents(".top").after('<div class="bottomall"><p class="tit" name= "' + sdmc + '" >' + sdmc + '预定</p></div>');
                                                                $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").after('<div class="bottom clearfloat" data-id="' + OnSaleId + '"><p name="' + name + '" class="fl"><span  name="ww"  style="color:black">' + name + '</span><span name="myPrice">' + price + '</span></p><div class="you clearfloat fr"><ul><li name="jianBtn" onclick="jianBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/minus.png" /></li><li name="myCount" >1</li><li name="jiaBtn" onclick="jiaBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/add2.png" /></li></ul></div>');
                                                            }
                                                            else {//有预定至少一种
                                                                $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").after('<div class="bottom clearfloat" data-id="' + OnSaleId + '"><p name="' + name + '" class="fl"><span  name="ww"  style="color:black">' + name + '</span><span name="myPrice">' + price + '</span></p><div class="you clearfloat fr"><ul><li name="jianBtn" onclick="jianBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/minus.png" /></li><li name="myCount" >1</li><li name="jiaBtn" onclick="jiaBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/add2.png" /></li></ul></div>');
                                                            }
                                                            $("[name='count']").text(function (n, c) { return Number(c) + 1 });
                                                            $("[name='sum']").text(function (n, c) { return (Number(c) + Number(price)).toFixed(2) });
                                                        }
                                                    } else {
                                                        if ($("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='" + sdmc + "']").text() == "") {
                                                            $("[name='" + datetime + "']").parents(".top").after('<div class="bottomall"><p class="tit" name="' + sdmc + '">' + sdmc + '预定</p></div>');
                                                            $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").after('<div class="bottom clearfloat" data-id="' + OnSaleId + '"><p name="' + name + '" class="fl"><span  name="ww"  style="color:black">' + name + '</span><span name="myPrice">' + price + '</span></p><div class="you clearfloat fr"><ul><li name="jianBtn" onclick="jianBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/minus.png" /></li><li name="myCount" >1</li><li name="jiaBtn" onclick="jiaBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/add2.png" /></li></ul></div>');
                                                        }
                                                        else {//有预定至少一种
                                                            $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").after('<div class="bottom clearfloat" data-id="' + OnSaleId + '"><p name="' + name + '" class="fl"><span  name="ww"  style="color:black">' + name + '</span><span name="myPrice">' + price + '</span></p><div class="you clearfloat fr"><ul><li name="jianBtn" onclick="jianBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/minus.png" /></li><li name="myCount" >1</li><li name="jiaBtn" onclick="jiaBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/add2.png" /></li></ul></div>');
                                                        }
                                                        $("[name='count']").text(function (n, c) { return Number(c) + 1 });
                                                        $("[name='sum']").text(function (n, c) { return (Number(c) + Number(price)).toFixed(2) });
                                                    }

                                                }
                                                else {   //不包含该日期则加入日期  
                                                    $(".sdetail").prepend(' <div class="all"><div class="top clearfloat" name="top"><div class="you clearfloat fl"><span class="datetime" name="' + datetime + '">' + datetime + '</span></div></div></div>');
                                                    if ($("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='" + sdmc + "']").text() == "") {
                                                        $("[name='" + datetime + "']").parents(".top").after('<div class="bottomall"><p class="tit" name="' + sdmc + '">' + sdmc + '预定</p></div>');
                                                        $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").after('<div class="bottom clearfloat" data-id="' + OnSaleId + '"><p name="' + name + '" class="fl"><span  name="ww"  style="color:black">' + name + '</span><span name="myPrice">' + price + '</span></p><div class="you clearfloat fr"><ul><li name="jianBtn" onclick="jianBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/minus.png" /></li><li name="myCount" >1</li><li name="jiaBtn" onclick="jiaBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/add2.png" /></li></ul></div>');
                                                    }
                                                    $("[name='count']").text(function (n, c) { return Number(c) + 1 });
                                                    $("[name='sum']").text(function (n, c) { return (Number(c) + Number(price)).toFixed(2) });
                                                }
                                                //订餐数量大于0才可以提交
                                                if ($('.sdetail').find(".bottom").length > 0) {
                                                    $('#determine').attr("onclick", "submit()");
                                                }
                                            }
                                        }
                                        else {
                                            var d = new Date();
                                            var getHours = d.getHours();
                                            var getMinutes = d.getMinutes();
                                            var getSeconds = d.getSeconds();
                                            var signs = ":";
                                            if (getHours >= 0 && getHours <= 9) {
                                                getHours = "0" + getHours;
                                            }
                                            if (getMinutes >= 0 && getMinutes <= 9) {
                                                getMinutes = "0" + getMinutes;
                                            }
                                            if (getSeconds >= 0 && getSeconds <= 9) {
                                                getSeconds = "0" + getSeconds;
                                            }

                                            var c = getHours + signs + getMinutes + signs + getSeconds;
                                            console.log("获取到当前时间：" + c + ",开始时间：" + cskssj + ",最后时间：" + csjssj);
                                            //if (new Date(a) > new Date(b)) {
                                            if (!(c >= cskssj && c <= csjssj)) {
                                                $(".weui-dialog__bd").html("此时段暂停服务，请在时段内进行购物！");
                                                $("#dialog").css("display", "block");
                                                return;
                                            }
                                            else {
                                                //添加购物车列表
                                                meunumberlist.push({ "onsaleid": OnSaleId, "name": name, "number": 1 });

                                                var myar = new Array();
                                                $($("[name='" + datetime + "']")).each(function () {
                                                    myar.push($(this).text());
                                                });
                                                var arr = new Array();
                                                $($("[name='" + datetime + "']").parents(".all").find(".tit")).each(function () {
                                                    arr.push($(this).attr("name"));
                                                });
                                                //debugger
                                                // 包含该日期
                                                if (myar.indexOf(datetime) != -1) {
                                                    var myarr = new Array();
                                                    $($("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='ww']")).each(function () {
                                                        myarr.push($(this).text());
                                                    });
                                                    if (arr.indexOf(sdmc) != -1) {//包含该时间段的菜品
                                                        if (myarr.indexOf(name) != -1) { //如果提交菜单弹出项已包含该菜品
                                                            $("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='" + sdmc + "']").siblings(".bottom").find("[name='" + name + "']").parents(".bottom").find("[name='myCount']").text(function (n, c) { return Number(c) + 1 });
                                                            $("[name='count']").text(function (n, c) { return Number(c) + 1 });
                                                            $("[name='sum']").text(function (n, c) { return (Number(c) + Number(price)).toFixed(2) });
                                                        } else {
                                                            if ($("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='" + sdmc + "']").text() == "") {
                                                                $("[name='" + datetime + "']").parents(".top").after('<div class="bottomall"><p class="tit" name= "' + sdmc + '" >' + sdmc + '预定</p></div>');
                                                                $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").after('<div class="bottom clearfloat" data-id="' + OnSaleId + '"><p name="' + name + '" class="fl"><span  name="ww"  style="color:black">' + name + '</span><span name="myPrice">' + price + '</span></p><div class="you clearfloat fr"><ul><li name="jianBtn" onclick="jianBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/minus.png" /></li><li name="myCount" >1</li><li name="jiaBtn" onclick="jiaBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/add2.png" /></li></ul></div>');
                                                            }
                                                            else {//有预定至少一种
                                                                $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").after('<div class="bottom clearfloat" data-id="' + OnSaleId + '"><p name="' + name + '" class="fl"><span  name="ww"  style="color:black">' + name + '</span><span name="myPrice">' + price + '</span></p><div class="you clearfloat fr"><ul><li name="jianBtn" onclick="jianBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/minus.png" /></li><li name="myCount" >1</li><li name="jiaBtn" onclick="jiaBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/add2.png" /></li></ul></div>');
                                                            }
                                                            $("[name='count']").text(function (n, c) { return Number(c) + 1 });
                                                            $("[name='sum']").text(function (n, c) { return (Number(c) + Number(price)).toFixed(2) });
                                                        }
                                                    } else {
                                                        if ($("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='" + sdmc + "']").text() == "") {
                                                            $("[name='" + datetime + "']").parents(".top").after('<div class="bottomall"><p class="tit" name="' + sdmc + '">' + sdmc + '预定</p></div>');
                                                            $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").after('<div class="bottom clearfloat" data-id="' + OnSaleId + '"><p name="' + name + '" class="fl"><span  name="ww"  style="color:black">' + name + '</span><span name="myPrice">' + price + '</span></p><div class="you clearfloat fr"><ul><li name="jianBtn" onclick="jianBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/minus.png" /></li><li name="myCount" >1</li><li name="jiaBtn" onclick="jiaBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/add2.png" /></li></ul></div>');
                                                        }
                                                        else {//有预定至少一种
                                                            $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").after('<div class="bottom clearfloat" data-id="' + OnSaleId + '"><p name="' + name + '" class="fl"><span  name="ww"  style="color:black">' + name + '</span><span name="myPrice">' + price + '</span></p><div class="you clearfloat fr"><ul><li name="jianBtn" onclick="jianBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/minus.png" /></li><li name="myCount" >1</li><li name="jiaBtn" onclick="jiaBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/add2.png" /></li></ul></div>');
                                                        }
                                                        $("[name='count']").text(function (n, c) { return Number(c) + 1 });
                                                        $("[name='sum']").text(function (n, c) { return (Number(c) + Number(price)).toFixed(2) });
                                                    }

                                                }
                                                else {   //不包含该日期则加入日期  
                                                    $(".sdetail").prepend(' <div class="all"><div class="top clearfloat" name="top"><div class="you clearfloat fl"><span class="datetime" name="' + datetime + '">' + datetime + '</span></div></div></div>');
                                                    if ($("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='" + sdmc + "']").text() == "") {
                                                        $("[name='" + datetime + "']").parents(".top").after('<div class="bottomall"><p class="tit" name="' + sdmc + '">' + sdmc + '预定</p></div>');
                                                        $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").after('<div class="bottom clearfloat" data-id="' + OnSaleId + '"><p name="' + name + '" class="fl"><span  name="ww"  style="color:black">' + name + '</span><span name="myPrice">' + price + '</span></p><div class="you clearfloat fr"><ul><li name="jianBtn" onclick="jianBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/minus.png" /></li><li name="myCount" >1</li><li name="jiaBtn" onclick="jiaBtn(\'' + name + '\',' + price + ',\'' + datetime + '\',\'' + sdmc + '\',\'' + OnSaleId + '\')"><img src="../images/newUI/add2.png" /></li></ul></div>');
                                                    }
                                                    $("[name='count']").text(function (n, c) { return Number(c) + 1 });
                                                    $("[name='sum']").text(function (n, c) { return (Number(c) + Number(price)).toFixed(2) });
                                                }
                                                //订餐数量大于0才可以提交
                                                if ($('.sdetail').find(".bottom").length > 0) {
                                                    $('#determine').attr("onclick", "submit()");
                                                }
                                            }
                                        }

                                    }
                                }
                            },
                            error: function () {
                                alert("异常！");
                            }
                        });
                    }
                },
                error: function () {
                    alert("无法校验商品份数异常！");
                    return false;
                }
            })

        }
        //提交菜单加号功能
        function jiaBtn(na, p, datetime, sdmc, OnSaleId) {

            var canteen = $("#canteen").val();
            //debugger
            $.ajax({
                type: "post",
                url: "../MenuReserveHandler.ashx",
                dataType: "json",
                async: false,
                data: { sdmc: sdmc, openid: $("#openid").text(), seldate_dummy: $("#seldate_dummy").val(), canteen: $("#canteen").val(), meunumberlist: JSON.stringify(meunumberlist), onsaleid: OnSaleId, funcName: 'meulimitnum' },
                success: function (data) {
                    if (data == false && canteen == "超市") {
                        alert("此商品已售完，无法购买，不便之处敬请谅解！");
                        return false;
                    }
                    else if (data == false && canteen != "超市") {
                        // alert("此商品已售完，无法购买，不便之处敬请谅解！");                        
                        alert("此时段订餐餐次已达上限，无法再次购买，不便之处敬请谅解！");
                        return false;
                    }
                    else {
                        meunumberlist.push({ "onsaleid": OnSaleId, "name": name, "number": 1 });
                        //debugger
                        $("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='" + sdmc + "']").siblings(".bottom").find("[name='" + na + "']").parents(".bottom").find("[name='myCount']").text(function (n, c) { return Number(c) + 1 });
                        $("[name='count']").text(function (n, c) { return Number(c) + 1 });
                        $("[name='sum']").text(function (n, c) { return (Number(c) + Number(p)).toFixed(2) });
                    }
                }, error: function () {
                    alert("无法校验商品份数异常！");
                    return false;
                }
            })

        };
        //提交菜单减号功能     
        function jianBtn(na, p, datetime, sdmc, OnSaleId) {


            $.ajax({
                type: "post",
                url: "../MenuReserveHandler.ashx",
                dataType: "json",
                async: false,
                data: { sdmc: sdmc, openid: $("#openid").text(), seldate_dummy: $("#seldate_dummy").val(), canteen: $("#canteen").val(), meunumberlist: JSON.stringify(meunumberlist), onsaleid: OnSaleId, funcName: 'meulimitnum' },
                success: function (data) {
                    debugger
                    for (var i = 0; i < meunumberlist.length; i++) {

                        if (meunumberlist[i].onsaleid == OnSaleId) {
                            meunumberlist.splice(i, 1);
                            break;
                        }

                    }
                },
                error: function () {
                    alert("无法校验商品份数异常！");
                    return false;
                }
            });


            //debugger
            var myPrice = $("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='" + sdmc + "']").siblings(".bottom").find("[name='" + na + "']").parents(".bottom").find("[name='myPrice']");
            var myCount = $("[name='" + datetime + "']").parents(".top").siblings(".bottomall").find("[name='" + sdmc + "']").siblings(".bottom").find("[name='" + na + "']").parents(".bottom").find("[name='myCount']");
            if (Number(myCount.text()) > 1) {//所减数量大于1
                myCount.text(function (n, c) { return Number(c) - 1 });
            } else {//所减数量小于1
                var aa = $("[name='" + datetime + "']").parents(".all").find(".bottom").length;
                if (aa == 1)//一个日期下只有一个菜
                {
                    $("[name='" + datetime + "']").parents(".all").remove();
                }
                else {//一个日期下有多个菜
                    var bb = $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").siblings(".bottom").length;
                    if (bb == 1) {//一个时间段下有一个菜
                        $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").siblings(".bottom").find("[name='" + na + "']").parents(".bottomall").remove();
                    }
                    else {//一个时间段下有多个菜
                        $("[name='" + datetime + "']").parents(".all").find("[name='" + sdmc + "']").siblings(".bottom").find("[name='" + na + "']").parents(".bottom").remove();
                    }
                }
                if ($('.all').length < 1) {//没有菜品时，不能提交
                    $('.sdetail').prepend('<div class="top clearfloat"><div class="you clearfloat fl"><p class="tit"></p><span style="text-align:center;margin-top:20px;">没有商品，请选择</span></div></div>');
                    $('#determine').removeAttr("onclick");
                }
            }
            $("[name='count']").text(function (n, c) { return Number(c) - 1 });
            $("[name='sum']").text(function (n, c) { return (Number(c) - Number(myPrice.text())).toFixed(2) });
        };






        $(document).on("click", "ul#ul li", function () {
            $(this).siblings('li').removeClass('current');  // 删除其他兄弟元素的样式
            $(this).addClass('current');                            // 添加当前元素的样式

            var FoodCategoryId = parseInt($(this).val());
            var Trade_name = $("#Trade_name").val();
            // alert("获取value值：" + FoodCategoryId);
            //删除所有值，然后赋值
            $("#content div").remove();
            // alert($(this).text());
            var stateq = state2;
            var rq = $("#seldate_dummy").val();
            var canteens = $("#canteen").val();
            $.ajax({
                type: "post",
                url: "../MenuReserveHandler.ashx",
                async: false,
                data: { TimeState: stateq, rr: rq, canteen: canteens, Trade_name: Trade_name, FoodCategoryId: FoodCategoryId, funcName: 'getMenuList' },
                success: function (data) {

                    if (data == null) return;
                    data = $.parseJSON(data);
                    var item = $.parseJSON(data.baseInfo);
                    $("#empty").remove();
                    if (item == null || item == "") {
                        $("#content").prepend('<div style="text-align:center;padding-top:3rem;" id="empty"><img src="../images/caip.png" style="width:2rem;"/><p style="padding-top:.3rem">商家未提供该时间段商品</p></div>');
                    }
                    else {
                        var Inventories = "";
                        for (var i = 0; i < item.length; i++) {
                            var menuName = item[i].Name;
                            var price = item[i].Price;
                            var state = item[i].TimeStateId;

                            //var OnSaleId = item[i].onsaleid;
                            var OnSaleId = item[i].OnSaleId1;
                            var Image = item[i].Image;
                            if (canteens == "超市") {
                                Inventories = item[i].Inventories;
                            }
                            else {
                                Inventories = item[i].ShelvesNum;
                            }
                            var sdmc = item[i].sdmc.trim() == "前夜餐" ? "夜宵" : item[i].sdmc.trim();
                            if (sdmc == "早餐") {
                                $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div class="tu clearfloat fl"><img src="../' + Image + '" onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a ><div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a> </div ></div ></div>');
                            }
                            else {
                                // $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div ><img src="../' + Image + '" onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a > <div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a>                        <span class="fr db" name="add" onclick="add(\'' + menuName + '\',' + price + ',\'' + sdmc + '\',' + OnSaleId + ')"><img src="../images/newUI/add.png" /></span></div><div> 剩余:' + Inventories + '</div>  </div ></div ></div>');
                                // $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div class="tu clearfloat fl"><img src="../' + Image + '" onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a > <div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a>                        <span class="fr db" name="add" onclick="add(\'' + menuName + '\',' + price + ',\'' + sdmc + '\',' + OnSaleId + ')"><img src="../images/newUI/add.png" /></span></div> <div> 剩余:' + Inventories + '</div> </div ></div ></div>');

                                if (canteens == "超市") {
                                    var myName = new Array();
                                    myName.push($(this).text());
                                    $($(".tit")).each(function () {
                                        myName.push($(this).text());
                                    });
                                    if (myName.indexOf(menuName) == -1) {
                                        $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div class="tu clearfloat fl"><img src="../' + Image + '" style="height:80px;" onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a > <div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a>                        <span class="fr db" name="add" onclick="add(\'' + menuName + '\',' + price + ',\'' + sdmc + '\',' + OnSaleId + ')"><img src="../images/newUI/add.png" /></span></div> <div> 剩余:' + Inventories + '</div> </div ></div ></div>');
                                    }
                                }
                                else {
                                    $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div class="tu clearfloat fl"><img src="../' + Image + '" style="height:80px;" onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a > <div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a>                        <span class="fr db" name="add" onclick="add(\'' + menuName + '\',' + price + ',\'' + sdmc + '\',' + OnSaleId + ')"><img src="../images/newUI/add.png" /></span></div> <div> 剩余:' + Inventories + '</div> </div ></div ></div>');
                                }
                            }

                            // $("#content").prepend('<div class="bottom clearfloat" name="menus" menuName="' + menuName + '" data-id="' + OnSaleId + '"> <div class="lie clearfloat"> <a href="#"><div class="tu clearfloat fl"><img src="../' + Image + '" onclick="tupian(\'../' + Image + '\')"/></div></a><div class="right clearfloat fl"><a href="#"><p class="tit">' + menuName + '</p></a > <div class="xia clearfloat"><a href="#"><p class="jifen fl over">￥' + price + '</p>  </a>                        <span class="fr db" name="add" onclick="add(\'' + menuName + '\',' + price + ',\'' + sdmc + '\',' + OnSaleId + ')"><img src="../images/newUI/add.png" /></span></div> <div> 剩余:' + Inventories + '</div> </div ></div ></div>');
                        }
                    }
                },
                error: function () {
                    alert("异常！");
                }
            });


        });




        var Autos = new Array();



        $(document).ready(function () {
            var openid = $("#openid").text();
            $.ajax({
                type: "post",
                url: "../MenuReserveHandler.ashx",
                dataType: "json",
                async: false,
                data: { openid: openid, funcName: 'getCanteen' },
                success: function (data) {
                    if (data == null || data == "") {
                        alert("请先添加食堂！");
                    } else {
                        var PowerValidate = $.parseJSON(data.baseInfos);
                        if (PowerValidate[0]["qx"] > 0) {

                            var canteen_arr = $.parseJSON(data.baseInfo);
                            $("#canteen").empty();
                            for (var i = 0; i < canteen_arr.length; i++) {
                                $("#canteen").append("<option  value=" + canteen_arr[i]["canteen_name"] + ">" + canteen_arr[i]["canteen_name"] + "</option>");

                            }

                        } else {
                            alert("此人卡类型无权限订餐！");
                            window.location.href = " ../index.html ";
                        }

                    }


                }


            })

            SelectTimeState('breakfast');


            $("#contentleft ul li").siblings('li').removeClass('current');  // 删除其他兄弟元素的样式
            $("#contentleft ul li:first").addClass('current');
        });




        var returntime = "";
        var reservationtime = "";
        var deductions = "";
        //根据不同类型，跳转至对应页面
        $(function () {
            $.ajax({
                type: "post",
                url: "../MenuReserveHandler.ashx",
                dataType: "json",
                async: false,
                data: { funcName: 'getall' },
                success: function (data) {
                    for (var i = 0; i < data.length; i++) {
                        var typename = data[i].typename;
                        var ismenu = data[i].ismenu;
                        deductions = data[i].deductions;
                        var reservationdays = data[i].reservationdays;
                        reservationtime = data[i].reservationtime;
                        returntime = data[i].returntime;
                        if (typename == "按餐就餐") {
                            if (ismenu == "否") {
                                window.location.href = "ReserveMenu0.aspx?openid=" + $("#openid").text();
                            } else {
                                $.ajax({
                                    type: "post",
                                    url: "../MenuReserveHandler.ashx",
                                    dataType: "json",
                                    async: false,
                                    data: { funcName: 'getdatatime', reservationdays: reservationdays },
                                    success: function (data) {
                                        // for (var i = 1; i < data.length; i++) {
                                        for (var i = 0; i < data.length; i++) {
                                            $("#seldate").append("<li>" + data[i] + "</li>");
                                        }
                                    },
                                    error: function () {
                                        alert("异常！");
                                    }
                                });
                            }
                        }
                        if (typename == "按天就餐") {
                            if (ismenu == "是") {
                                window.location.href = "ReserveMenu2.aspx?openid=" + $("#openid").text();
                            }
                            else {
                                window.location.href = "ReserveMenu1.aspx?openid=" + $("#openid").text();
                            }
                        }
                    }
                },
                error: function () {
                    alert("异常！");
                }
            });

            $("#canteen").change(function () {

                $(".all").empty();
                $("#sum").empty();
                $("[name='count']").empty();
                SelectTimeState(state2);
            });

            //不可预定操作
            $("#seldate").change(function () {
                $.ajax({
                    type: "post",
                    url: "../MenuReserveHandler.ashx",
                    dataType: "json",
                    async: false,
                    data: { funcName: 'Notorder' },
                    success: function (data) {
                        var time = {};
                        var tt = new Array();
                        for (var i = 0; i < data.length; i++) {
                            var remark = data[i].remark;
                            var str = data[i].notorderDate;
                            var tmp = /\d+(?=\+)/.exec(str);
                            var d = new Date(+tmp);
                            var notorderDate = "";
                            //发布是取消注释
                            notorderDate = d.getFullYear() + '/' + (+d.getMonth() + 1) + '/' + d.getDate();

                            var ww = $("#seldate_dummy").val();
                            if (notorderDate == ww) {
                                $(".weui-dialog__bd").html("" + ww + "不能订餐</br>" + remark + "");
                                $("#dialog").css("display", "block");
                                $("#seldate_dummy").val("");
                            }
                        }
                    },
                    error: function () {
                        alert("异常！");
                    }
                });

                $(".all").empty();
                $("#sum").empty();
                $("[name='count']").empty();
                //state=$().
                SelectTimeState(state2);
            });

            //日期
            $("#seldate").mobiscroll().treelist({
                theme: "android-ics light",
                lang: "zh",
                cancelText: null,
                headerText: "选择日期",
                formatResult: function (array) {

                    return $('#seldate>li').eq(array[0]).text();
                }
            });




        })

        $(document).ready(function () {
            var rr = new Date();
            //rr = new Date( rr.setDate(rr.getDate() + 1));     
            rr = rr.getFullYear() + "-" + (rr.getMonth() + 1) + "-" + rr.getDate();
            // tt.setDate(tt.getDate() + 6);
            $("#seldate_dummy").val(rr);


        });

        function getFoodCategoryTwo() {

            var canteen = $("#canteen").val();

            $.ajax({
                type: "post",
                url: "../MenuReserveHandler.ashx",
                data: { canteen: canteen, funcName: "getFoodCategoryTwo" },
                dataType: "json",
                success: function (data) {
                    if (data == null) {
                        return false;
                    }


                    $("#contentleft ul li").empty();//清空                    
                    $("#contentleft ul").append("<li class='current' value=''>全部搜索</li>");//赋值

                    //var item = data.row;
                    var items = $.parseJSON(data.rows);
                    for (var i = 0; i < items.length; i++) {
                        $("#contentleft ul").append("<li value='" + items[i].FoodCategoryId + "'>" + items[i].Name + "</li>");
                    }
                }
            });
        }


    </script>
</head>
<!--loading页开始-->
<div class="loading">
    <div class="loader">
        <div class="loader-inner pacman">

            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
</div>
<!--loading页结束-->
<body>

    <!--header star-->
    <%--<header class="mui-bar mui-bar-nav report-header box-s" id="header">
			<a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl"></i></a>
			<p>订餐系统</p>
            
	    </header>--%>
    <%-- <header class="mui-bar mui-bar-nav" id="header" style="position:fixed">
        <a class="btn" href="javascript:history.go(-1)">
            <i class="iconfont icon-fanhui"></i>
        </a>
        <div class="top-sch-box flex-col">
            <div class="centerflex">
                <i class="fdj iconfont icon-sousuo"></i>
                <input type="text"  id="MenuName" value="" class="sch-txt" placeholder="输入您要搜索的菜品" />
            </div>
        </div>
        <a class="btn" href="#">
            <i class="iconfont icon-gouwuche"></i>
            <span>2</span>
        </a>
    </header>--%>
    <!--header end-->

    <div class="warp clearfloat">
        <div class="lists clearfloat">
            <div style="width: 100%; position: fixed; z-index: 10" id="tops">
                <div class="time clearfloat">
                    <span style="display: none" id="openid"><%=openid%></span>
                    <ul>
                        <%--                        <li style="width: 5%;"><a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl" style="color: white;"></i></a></li>--%>
                        <li style="width: 35%;">选择日期/食堂</li>
                        <li style="width: 35%; text-align: left; color: black;">
                            <ul id="seldate" style="text-align: center">
                            </ul>

                        </li>

                        <%--<li  >选择食堂</li>--%>
                        <li style="width: 25%; text-align: left; color: black;">
                            <select name="canteen" id="canteen">
                                <%--  <option value="A食堂">A食堂</option>
                            <option value="B食堂">B食堂</option>--%>
                            </select>

                        </li>

                    </ul>
                </div>
                <div class="time clearfloat" style="text-align: center;">
                    <input type="text" placeholder="请输入商品名称" style="width: 60%; border: 1px solid #fff;" id="Trade_name" />
                </div>

                <div class="order-top clearfloat">
                    <ul>
                        <li class="clearfloat"><a href="#">时间段</a></li>
                        <li class="clearfloat" onclick="SelectTimeState('breakfast')" id="breakfast"><a href="#">早餐</a></li>
                        <li class="clearfloat" onclick="SelectTimeState('lunch')" id="lunch"><a href="#">中餐</a></li>
                        <li class="clearfloat" onclick="SelectTimeState('dinner')" id="dinner"><a href="#">晚餐</a></li>
                        <li class="clearfloat" onclick="SelectTimeState('midnightSnack')" id="midnightSnack" style="display: none;"><a href="#">超市</a></li>
                        <li class="clearfloat" onclick="SelectTimeState('supermarket')" id="supermarket" style="display: none;"><a href="#">超市</a></li>
                    </ul>
                </div>
            </div>
            <div style="clear: both; padding-top: 4.5rem; width: 100%;">
                <div id="contentleft" style="width: 28%; float: left; position: fixed;">
                    <ul id="ul">
                        <%--                 <li class="current" value="">全部搜索</li>--%>
                    </ul>
                </div>
                <div id="content" style="width: 70%; float: right">
                </div>
            </div>


            <%--            <div id="content" style="clear: both; padding-top: 3rem;"></div>--%>
            <%--  <div class="bottom clearfloat">
            <div class="lie clearfloat">
						<a href="detail.html">
							<div class="tu clearfloat fl">
								<img src="upload/20.jpg"/>
							</div>
						</a>
						<div class="right clearfloat fl" style="">
							<a href="detail.html">
								<p class="tit">美国阿拉斯加黑鳕鱼（冻黑鳕鱼）</p>
							</a>
							<div class="xia clearfloat">
								<a href="detail.html">
									<p class="jifen fl over">2998</p>
								</a>
								<span class="fr db" name="add" id="add"><img src="../images/jia.png"/></span>
							</div>
						</div>
					</div>
				</div>--%>
        </div>
    </div>
    <!--footerone star-->
    <div class="settlement clearfloat" style="display: none;">
        <div class="zuo clearfloat fl box-s">
            共<span name="count">0</span>件  总金额：￥<span name="sum">0</span>
        </div>
        <a href="#" class="fl db">提交订单
        </a>
    </div>
    <!--footerone end-->

    <!--这里是弹出购物车内容-->
    <div class="am-share">
        <div class="am-share-footer">

            <button class="share_btn">
                <img src="../images/chahao.png" />
            </button>
        </div>
        <div class="am-share-sns box-s" style="overflow: auto">
            <div class="sdetail clearfloat">
                <%--  <div class="all">
                    <div class="top clearfloat">
                        <div class="you clearfloat fl">
                              <span>日期 4月13号</span>
                           
                          
                        </div>
                    </div>
                    <div class="bottomall">
                        <p class="tit">午餐预定</p>
                         	<div class="bottom clearfloat">
                                
		     		<p class="fl">菜单1 <span name="myPrice">10</span></p>
		     		<div class="you clearfloat fr">
		     			<ul>
		     				<li name="jianBtn"><img src="../images/jian.jpg"/></li>
		     				<li name="myCount">1</li>   
		     				<li name="jiaBtn"><img src="../images/jia.jpg"/></li>
		     			</ul>
		     		</div>
		     	</div>
                   <div class="bottom clearfloat">
		     		<p class="fl">菜单2 <span name="myPrice">10</span></p>
		     		<div class="you clearfloat fr">
		     			<ul>
		     				<li name="jianBtn"><img src="../images/jian.jpg"/></li>
		     				<li name="myCount">2</li>
		     				<li name="jiaBtn"><img src="../images/jia.jpg"/></li>
		     			</ul>
		     		</div>
		     	</div>
                        </div>
                      <div class="bottomall">
                        <p class="tit">午餐预定</p>
                         	<div class="bottom clearfloat">
                                
		     		<p class="fl">菜单1 <span name="myPrice">10</span></p>
		     		<div class="you clearfloat fr">
		     			<ul>
		     				<li name="jianBtn"><img src="../images/jian.jpg"/></li>
		     				<li name="myCount">1</li>
		     				<li name="jiaBtn"><img src="../images/jia.jpg"/></li>
		     			</ul>
		     		</div>
		     	</div>
                   <div class="bottom clearfloat">
		     		<p class="fl">菜单2 <span name="myPrice">10</span></p>
		     		<div class="you clearfloat fr">
		     			<ul>
		     				<li name="jianBtn"><img src="../images/jian.jpg"/></li>
		     				<li name="myCount">2</li>
		     				<li name="jiaBtn"><img src="../images/jia.jpg"/></li>
		     			</ul>
		     		</div>
		     	</div>
                          </div>
                        </div>--%>
                <div class="confirm clearfloat">
                    <div class="gmshu clearfloat box-s fl">

                        <p class="fr">共<span name="count">0</span>件商品   合计￥<samp name="sum" id="sum">0</samp></p>

                    </div>
                    <button class="share_btn" style="width: 40px; height: 40px; font-size: 16px; background-color: #3d67a5; color: #ffffff; float: right;">
                        返  回
                    </button>
                </div>
            </div>
        </div>
        <a href="#" onclick="submit()" class="shop-btn db" id="determine">确  定</a>
    </div>
    <div style="display: none;" id="dialog">
        <div class="weui-mask"></div>
        <div class="weui-dialog">
            <div class="weui-dialog__hd"><strong class="weui-dialog__title">提示</strong></div>
            <div class="weui-dialog__bd"></div>
            <div class="weui-dialog__ft">
                <a href="javascript:$('#dialog').hide();" class="weui-dialog__btn weui-dialog__btn_primary" id="que">确定</a>
            </div>
        </div>
    </div>
    <div id="toast" style="display: none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-icon-success-no-circle weui-icon_toast"></i>
            <p class="weui-toast__content">订餐成功！</p>
        </div>
    </div>
    <!--footer star-->
    <footer class="page-footer fixed-footer" id="footer">
        <ul>
            <%-- <li>
                    <a href="index.html">
                        <i class="iconfont icon-shouye" style=""></i>
                        <p>首页</p>
                    </a>
                </li>--%>
            <li class="active">
                <a href="#">
                    <i class="iconfont icon-swticondingcan"></i>
                    <p>在线订餐</p>
                </a>
            </li>


            <li class="center">

                <a href="#" onclick="toshare()">

                    <span name="count" style="border: solid 1px red; width: 20px; height: 20px; border-radius: 10px; text-align: center; color: white; font-size: 12px; line-height: 15px; position: absolute; background-color: red; left: 50%;">0</span>
                    <i class="iconfont icon-gouwuche"></i>


                    <p>购物车</p>
                </a>
            </li>


            <li class="right">
                <a href="OrderList1.aspx?openid=<%=openid%>&type=list0">
                    <i class="iconfont icon-dingdan"></i>
                    <p>我的订单</p>
                </a>
            </li>
            <%-- <li>
                    <a href="login.html">
                        <i class="iconfont icon-yonghuming"></i>
                        <p>个人中心</p>
                    </a>
                </li>--%>
        </ul>
    </footer>
    <!--footer end-->
</body>

</html>
